package api.one.run;
import api.one.mapper.usermapper;
import api.one.pojo.user;
import net.minidev.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api")
public class home {

    @GetMapping("/apihome")
    public int add(){
        return 3;
    }
    @PostMapping("/apihomrs")
    public int adds(@RequestBody JSONObject js){
        int a = (int) js.getAsNumber("nn");
        int b = (int) js.getAsNumber("nm");
        return a+b;
    }
    @Autowired
    private usermapper usermapper;

    @PostMapping("/apidl")
    public int dl(@RequestBody JSONObject js){
        user a = new user();
        a.setPass((String) js.get("pass"));
        a.setValue((String) js.get("value"));
        List<user> a1 = usermapper.kc(a);
        if (a1.size() == 0){
            return 0;
        }
        return 1;
    }

}
